﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
namespace _22_BanVeGaSaiGon
{
    public partial class Frm01_NVBV : Office2007Form
    {
        public Frm01_NVBV()
        {
            InitializeComponent();
        }

        DataTable dt = new DataTable();
        XuLy_NhanVienVanVe xl = new XuLy_NhanVienVanVe();
        private void Frm01_NhanVienBanVe_Load(object sender, EventArgs e)
        {
            ThongTinChoKhachHang();
            DSGaDiQua();
            GiaVe();
        }

        private void txtmact_Click(object sender, EventArgs e)
        {
            Frm03_TruongGa g = new Frm03_TruongGa();
            g.ShowDialog();
        }

        private void btnDatVe_Click(object sender, EventArgs e)
        {
            int dong = Convert.ToInt32(dtgTTChuyenTau.CurrentRow.Index);
            string maTau = Convert.ToString(dtgTTChuyenTau.Rows[dong].Cells["MaTau"].Value.ToString());
            Frm01_NVBV_DatVe datve = new Frm01_NVBV_DatVe();
            datve.MaTau = maTau;
            datve.Show();
        }

        private void ThongTinChoKhachHang()
        {
            dt = xl.ThongTinChoHanhKhach();
            dtgTTChuyenTau.DataSource = dt;

        }

        private void DSGaDiQua()
        {
            int dong = Convert.ToInt32(dtgTTChuyenTau.CurrentRow.Index);
            string maChuyenTau = Convert.ToString(dtgTTChuyenTau.Rows[dong].Cells[0].Value.ToString());
            dt = xl.GaDiQua(maChuyenTau);
            dtgGaDiQua.DataSource = dt;
        }

        private void GiaVe()
        {
            try
            {
                int dong = Convert.ToInt32(dtgTTChuyenTau.CurrentRow.Index);
                string maChuyenTau = Convert.ToString(dtgTTChuyenTau.Rows[dong].Cells["MaChuyenTau"].Value.ToString());
                //string maChuyenTau = "abc";
                //DataTable dt = new DataTable();
                //XuLy_NhanVienVanVe gv = new XuLy_NhanVienVanVe();
                dt = xl.GiaVe(maChuyenTau);

                lblGheCung.Text = dt.Rows[0][2].ToString();
                lblGheMemDH.Text = dt.Rows[1][2].ToString();
                lblGiuongNam.Text = dt.Rows[2][2].ToString();
            }
            catch { }
        }
        private void dtgTTChuyenTau_SelectionChanged(object sender, EventArgs e)
        {
            //ThongTinChoKhachHang();
            DSGaDiQua();
            GiaVe();
        }
        private void buttonX1_Click(object sender, EventArgs e)
        {
            DateTime ngayKH = Convert.ToDateTime(dtime_NgayDi.Text);
            string diemKT = Convert.ToString(txtDDDen.Text);

            dt = xl.TraCuuChuyenTau(ngayKH, diemKT);
            dtgTTChuyenTau.DataSource = dt;
        }

        private void btnTraCuu_Click(object sender, EventArgs e)
        {
            dt = xl.TraCuuThongTinVe(int.Parse(txtMaVe.Text));
            dtg_VeTau.DataSource = dt;
        }
    }
}
